<template>
    <div>
        <el-cascader :props="props"></el-cascader>
    </div>
</template>


<script>
    let id = 0;
    import {Cascader} from 'element-ui'
    export default {
        name:'cascader',
        components:{
            'el-cascader':Cascader
        },
        data() {
            return {
                props: {
                    lazy: true,
                    lazyLoad (node, resolve) {
                        const { level } = node;

                        setTimeout(() => {

                            const nodes = Array.from({ length: level + 1 })
                                .map(() => ({
                                    value: ++id,
                                    label: `选项${id}`,
                                    leaf: level >= 1
                                }));
                            // 通过调用resolve将子节点数据返回，通知组件数据加载完成
                            resolve(nodes);
                            console.info(nodes)
                        }, 1000);
                    }
                }
            };
        }
    };
</script>